﻿
@{
    ViewBag.Title = "菜单管理";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@model IList<Mate.Dto.System.MenuModel>
@section styles{

    <link href="~/bootstrap/plugins/treegrid/jquery.treegrid.css" rel="stylesheet" />
}

@section scripts{

    <script src="~/bootstrap/plugins/treegrid/jquery.treegrid.js"></script>
    <script src="~/bootstrap/plugins/treegrid/jquery.treegrid.bootstrap3.js"></script>

    <script type="text/javascript">
        $(function () {
            $('.tree').treegrid();


        });

        function Remove(id){
            layer.confirm('确定要删除？', {
                btn: ['删除', '取消'] //按钮
            }, function () {
                $.post("@Url.Action("Remove")", { id: id }, function (result) {
                    if (result.resultCode == 1000) {
                        layer.msg(result.message, {
                            icon: 1,
                            time: 1500
                        }, function () {
                            location.href = location.href;
                        });
                    } else {
                        layer.open({
                            content: result.message
                        });
                    }

                });
            });
        }
    </script>
}

    <ul class="page-breadcrumb breadcrumb">
        <li>
            <a href="@Url.Action("Index", "Menu")">
                菜单管理
            </a>
        </li>
    </ul>

<div class="row">

    <div class="col-md-12">
            <div class="portlet-body">
                <div class="row">
                    <div class="form-group">
                        <div class="col-md-8">
                            <div class="btn-group btn-group-solid">
                                <a href="@Url.Action("Create")" class="btn green" role="button" title="新增"><i class="fa fa-plus"></i> 新增</a>
                            </div>
                        </div>
                    </div>
                </div><br />
                <table class="tree table table-hover table-bordered table-condensed">
                    <tr>
                        <th>菜单标题</th>
                        <th>图标</th>
                        <th>Url</th>
                        <th>菜单类型</th>
                        <th>排序</th>
                        <th>操作</th>
                    </tr>
                    @if (Model != null)
                    {
                        foreach (var menu1 in Model)
                        {
                            <tr class="treegrid-@(menu1.id)">
                                <td>@(menu1.menu_name)</td>
                                <td><i class="@(menu1.icons)"></i></td>
                                <td>@(menu1.controller_name)/@(menu1.action_name)@(menu1.url_parameter)</td>
                                <td><span style='color:@(menu1.menu_type==1?"green":"blue");'>@(menu1.menu_type == 1 ? "菜单" : "按钮")</span></td>
                                <td>@menu1.order_by</td>
                                <td>
                                    <a href="@Url.Action("Edit")/@(menu1.id)" class="btn btn-xs green"><i class="fa fa-edit"></i> 修改 </a>
                                    <a href="javascript:void(0);" onclick="Remove('@menu1.id');" class="btn btn-xs yellow" role="button" title="删除"><i class="fa fa-times"></i> 删除</a>
                                </td>
                            </tr>
                            if (menu1.children.Any())
                            {
                                foreach (var menu2 in menu1.children)
                                {
                                    <tr class="treegrid-@(menu2.id) treegrid-parent-@(menu1.id)">
                                        <td>@(menu2.menu_name)</td>
                                        <td><i class="@(menu2.icons)"></i></td>
                                        <td>@(menu2.controller_name)/@(menu2.action_name)@(menu2.url_parameter)</td>
                                        <td><span style='color:@(menu2.menu_type==1?"green":"blue");'>@(menu2.menu_type == 1 ? "菜单" : "按钮")</span></td>
                                        <td>@menu2.order_by</td>
                                        <td>
                                            <a href="@Url.Action("Edit")/@(menu2.id)" class="btn btn-xs green"><i class="fa fa-edit"></i> 修改 </a>
                                            <a href="javascript:void(0);" onclick="Remove('@menu2.id');" class="btn btn-xs yellow" role="button" title="删除"><i class="fa fa-times"></i> 删除</a>
                                        </td>
                                    </tr>
                                    if (menu2.children.Any())
                                    {
                                        foreach (var menu3 in menu2.children)
                                        {
                                            <tr class="treegrid-@(menu3.id) treegrid-parent-@(menu2.id)">
                                                <td>@(menu3.menu_name)</td>
                                                <td><i class="@(menu3.icons)"></i></td>
                                                <td>@(menu3.controller_name)/@(menu3.action_name)@(menu3.url_parameter)</td>
                                                <td><span style='color:@(menu3.menu_type==1?"green":"blue");'>@(menu3.menu_type == 1 ? "菜单" : "按钮")</span></td>
                                                <td>@menu3.order_by</td>
                                                <td>
                                                    <a href="@Url.Action("Edit")/@(menu3.id)" class="btn btn-xs green"><i class="fa fa-edit"></i> 修改 </a>
                                                    <a href="javascript:void(0);" onclick="Remove('@menu3.id');" class="btn btn-xs yellow" role="button" title="删除"><i class="fa fa-times"></i> 删除</a>
                                                </td>
                                            </tr>
                                        }
                                    }
                                }
                            }
                        }

                    }
                </table>

            </div>
        </div>
    </div>

